<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="clientUpdateForm" :model="clientUpdateFormData" :rules="rules" size="mini"
        label-width="100px">
        <el-col :span="12">
          <el-form-item label="客户ID" prop="clientId">
            <el-input v-model="clientUpdateFormData.clientId" placeholder="请输入客户ID" readonly :disabled='true'
              prefix-icon='el-icon-user' :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="地址" prop="clientAddress">
            <el-input v-model="clientUpdateFormData.clientAddress" placeholder="请输入地址" :maxlength="100"
              show-word-limit clearable prefix-icon='el-icon-add-location' :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户姓名" prop="clientName">
            <el-input v-model="clientUpdateFormData.clientName" placeholder="请输入客户姓名" :maxlength="20"
              show-word-limit clearable prefix-icon='el-icon-user-solid' :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="性别" prop="clientSex">
            <el-select v-model="clientUpdateFormData.clientSex" placeholder="请选择性别" :style="{width: '100%'}">
              <el-option v-for="(item, index) in clientSexOptions" :key="index" :label="item.label"
                :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系方式" prop="clientPhone">
            <el-input v-model="clientUpdateFormData.clientPhone" placeholder="请输入联系方式" :maxlength="11"
              show-word-limit clearable prefix-icon='el-icon-mobile-phone' :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
import { clientUpdate } from '@/api/sale'

export default {
  components: {},
  props: ['clientUpdateData'],
  data() {
    return {
      clientUpdateFormData: {
        clientId: undefined,
        clientAddress: undefined,
        clientName: undefined,
        clientSex: 0,
        clientPhone: undefined,
      },
      rules: {
        clientId: [{
          required: true,
          message: '请输入客户ID',
          trigger: 'blur'
        }],
        clientAddress: [{
          required: true,
          message: '请输入地址',
          trigger: 'blur'
        }],
        clientName: [{
          required: true,
          message: '请输入客户姓名',
          trigger: 'blur'
        }],
        clientSex: [{
          required: true,
          message: '请选择性别',
          trigger: 'change'
        }],
        clientPhone: [{
          required: true,
          message: '请输入联系方式',
          trigger: 'blur'
        }],
      },
      clientSexOptions: [{
        "label": "男",
        "value": 0
      }, {
        "label": "女",
        "value": 1
      }],
    }
  },
  computed: {},
  watch: {
    clientUpdateData: function(n , o){
      this.clientUpdateFormData = n
    }
  },
  created() {
    this.clientUpdateFormData = this.clientUpdateData
  },
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['clientUpdateForm'].validate(valid => {
        if (!valid) return
        clientUpdate(this.clientUpdateFormData).then()
      })
    },
    resetForm() {
      this.$refs['clientUpdateForm'].resetFields()
    },
  }
}

</script>
<style>
</style>
